<?php
namespace app\apiadmin\controller\choujiang;

use app\apiadmin\model\choujiang\ChouJiangModel;
use app\common\controller\BaseController;
use app\common\utils\Res;
use think\facade\Db;
use think\facade\Log;

class Prize extends BaseController
{
    public function index()
    {
        $logs = Log::getLog();
        dd($logs);
    }

    /**
     * 新增抽奖
     * @return \think\response\Json
     */
    public function add()
    {
        $param = $this->request->post();
        $result = ChouJiangModel::getadd($param);
        return $result;
    }

    /**
     * 编辑
     * @return null
     */
    public function editPrize()
    {
        $param = $this->request->post();
        $result = ChouJiangModel::editPrize($param);
        return $result;
    }

    /**
     * 发起抽奖
     * @return \think\response\Json
     */
    public function sendPrize()
    {
        $param = $this->request->post();
        if (!$param["liveId"]) {
            return Res::error("参数错误");
        }
        if (!$param["id"]) {
            return Res::error("参数错误");
        }
      
        $result = ChouJiangModel::sendPrize($param);
        return $result;
    }

    /**
     * 倒计时结束抽奖
     * @return null
     */
    public function getfinish()
    {
        $param = $this->request->post();
        $id = $param['id'];
        $result = ChouJiangModel::getfinish($id);
        return $result;
    }
    /**
     * 手动结束抽奖
     * @return \think\response\Json
     */
    public function finishPrize()
    {
        $param = $this->request->post();
        if (!$param["id"]) {
            return Res::error("参数错误");
        }
        $id = $param['id'];
        $result = ChouJiangModel::finishPrize($id);
        return $result;
    }

    /**
     * 开奖
     * @return \think\response\Json
     */
   public function addLottery()
   {
       $param = $this->request->post();
       $result = ChouJiangModel::getaddLottery($param);
       return $result;
   }
}
